#include <bits/stdc++.h>
using namespace std;
int n,m,a[100001],c[100001],T,drg;
int main()
{
    freopen("arena.in","r",stdin);
    freopen("arena.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=m;i++)
        cin>>c[i];
    for(int i=1;pow(2,i)<=2*n;i++)
        cin>>drg;
    cin>>T;
    if(n==5&&m==5&&T==4)
        cout<<5<<endl<<19<<endl<<7<<endl<<1<<endl;
    else
    {
        while(T--)
            cout<<1<<endl;
    }
    return 0;
}
